<<<<<<< HEAD
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/**
 * 自动投标设置
 * @author chenhuan
 *
 */
class Borrowauto extends MY_Controller {
	function __construct(){
		parent::__construct();
		/** 登陆验证 */
		$user = $this->session->userdata('rsh_user');
		if(!isset($user['user_id'])){
			$this->js->go('/login.html');
			exit;
		}
		
		$this->tab = 'user';
		$this->sub = 'tender';
	}
	
	/**
	 * 添加自动发标
	 * @param $ftype 标类型
	 */
	function add_view(){
		$this->load->helper(array('form'));
		$this->load->model('Borrow_model');
		$data = $this->get_user_info('borrowauto_add','alist');
		$this->load->model('Account_model', 'account');
		$account = $this->account->get_account($data['user']['user_id']);
		$data['account'] = $account;
		$data['borrow_type'] 			= $this->Borrow_model->arrays('borrow_type');//标的类型
		$data['borrow_time_limit'] 		= $this->Borrow_model->arrays('borrow_time_limit');//借款期限
		$data['borrow_style'] 			= $this->Borrow_model->arrays('borrow_style');//还款方式
		$data['borrow_conset_credit'] 		= $this->Borrow_model->arrays('borrow_conset_credit');//标的等级
		$data['title'] 					= "自动投标设置".' - '.CON_KEYWORDS; 
		$data['valid_start_time'] = date('Y-m-d',time());
		$data['valid_end_time'] = date('Y-m-d',time()+2*3600*24);
		$data['typer'] = "add";
		$data['sub'] = "tender";
		$data['user_sub'] = "tender_invself";
		$data['sub_1'] = "会员中心";
		$data['sub_1_href'] = "/user/zhs_center.html";
		$data['sub_2'] = "自动投标";
		$data['sub_2_href'] = "/borrowauto/zhs_alist.html";
		$data['sub_3'] = "添加自动发标";
		$data['sub_3_href'] = "/borrowauto/add_view.html";
		$this->load->view('user/zhs_user_borrow_auto_add', $data);
	}
	
	/**
	 *	新增自动购买标的
	 */
	function add(){
		$ret = array(
			'msg' => '',
			'url' => '',
		);
		$fstatus 				= $this->input->post("fstatus");//是否启用
		$tender_type 				= $this->input->post("tender_type");//标的类型
		$tender_account_min 		= $this->input->post("tender_account_min");//按金额，最大金额
		$tender_account_max 		= $this->input->post("tender_account_max");//按金额，最小金额
		$borrow_style_status 			= $this->input->post("borrow_style_status")?$this->input->post("borrow_style_status"):'0';//还款方式
		$retain_money_status			= $this->input->post("retain_money_status")?$this->input->post("retain_money_status"):'0';//保留金额
		$timelimit_status 			= $this->input->post("timelimit_status")?$this->input->post("timelimit_status"):'0';//标的期限
		$apr_status 			= $this->input->post("apr_status")?$this->input->post("apr_status"):'0';//利率选项
		$award_status 			= $this->input->post("award_status")?$this->input->post("award_status"):'0';//奖励选项
		//$credit_rating_status			= $this->input->post("credit_rating_status")?$this->input->post("credit_rating_status"):'0';//信誉等级
		
		$valid_start_time_post = $this->input->post("valid_start_time");
		$valid_end_time_post = $this->input->post("valid_end_time");
		$valid_start_time 			= strtotime($valid_start_time_post.' 00:00:00');//有效开始时间
		$valid_end_time 			= strtotime($valid_end_time_post.' 23:59:59');//有效结束时间
		
		$user = $this->session->userdata('rsh_user');
		$data['user_id']= $user['user_id'];
		
		$this->load->model('Borrow_model');
		if(!array_key_exists($tender_type,$this->Borrow_model->arrays('borrow_type'))){
			$ret['msg'] = '标的类型无效';
		}elseif(!$this->myformcheck->IsDouble($tender_account_min) || !$this->myformcheck->IsDouble($tender_account_max)){
			$ret['msg'] = '单笔投资金额无效';
		}elseif($tender_account_min > $tender_account_max){
			$ret['msg'] = '单笔最小投资金额不能大于最大投资金额';
		}elseif($tender_account_min <50){
			$ret['msg'] = '单笔最小投资金额不能小于50';
		}elseif($tender_account_max > 100000){
			$ret['msg'] = '单笔最大投资金额不能大于10W';
		}elseif($borrow_style_status != "1" && $borrow_style_status != "0"){
			$ret['msg'] = '还款方式是否启动无效';
		}elseif($retain_money_status != "1" && $retain_money_status != "0"){
			$ret['msg'] = '保留金额是否启动无效';
		}elseif($timelimit_status != "1" && $timelimit_status != "0"){
			$ret['msg'] = '标的期限是否启动无效';
		}/*elseif($apr_status != "1" && $apr_status != "0"){
			$ret['msg'] = '利率选项是否启动无效';
		}*/elseif($award_status != "1" && $award_status != "0"){
			$ret['msg'] = '奖励选项是否启动无效';
		}elseif($valid_start_time > $valid_end_time){
			$ret['msg'] = '开始时间不能大于结束时间';	
		}
		$id = '';
		
		$typer = $this->input->post("typer");
		if($typer == 'update') $id = $this->input->post("id");
		if(!$this->Borrow_model->is_date_borrow_auto(array('user_id'=>$data['user_id'],'valid_start_time'=>$valid_start_time,'valid_end_time'=>$valid_end_time,'id'=>$id))){
			$ret['msg'] = '开始时间与结束时间不可与其它自动投标的时间重合';
		}
		if($typer != 'update'){
			$count = $this->Borrow_model->count_borrow_auto(array('user_id'=>$data['user_id'])); 
			if($count > 2) {
				$ret['msg'] = '您最多可以创建 3 条自动投标规则';
			}
		}
		if($ret['msg']){
			echo json_encode($ret);exit;
		}
		
		if($borrow_style_status == "1"){
			$borrow_style = $this->input->post("borrow_style");
			if(!array_key_exists($borrow_style,$this->Borrow_model->arrays('borrow_style'))){
				$ret['msg'] = '还款方式无效';
			}
			else {
				$data['borrow_style_status'] = $borrow_style_status;
				$data['borrow_style'] = $borrow_style;
			}
		}
		else {
			$data['borrow_style_status'] = $borrow_style_status;
			$data['borrow_style'] = '';
		}
		if($retain_money_status == "1"){
			$retain_money = $this->input->post("retain_money");
			if(!$this->myformcheck->IsDouble($retain_money)){
				$ret['msg'] = '保留金额无效';
			}
			else {
				$data['retain_money_status'] = $retain_money_status;
				$data['retain_money'] = $retain_money;
			}
		}
		else {
			$data['retain_money_status'] = $retain_money_status;
			$data['retain_money'] = '0.00';
		}
		
		if($timelimit_status == "1"){
			$timelimit_month_first = $this->input->post("timelimit_month_first");
			$timelimit_month_last = $this->input->post("timelimit_month_last");
			if(!array_key_exists($timelimit_month_first,$this->Borrow_model->arrays('borrow_time_limit')) || !array_key_exists($timelimit_month_last,$this->Borrow_model->arrays('borrow_time_limit'))){
				$ret['msg'] = '标的期限无效';
			}
			elseif($timelimit_month_first > $timelimit_month_last){
				$ret['msg'] = '标的最小期限不能大于最大期限';
			}
			else {
				$data['timelimit_status'] = $timelimit_status;
				$data['timelimit_month_first'] = $timelimit_month_first;
				$data['timelimit_month_last'] = $timelimit_month_last;
			}
		}
		else {
			$data['timelimit_status'] = $timelimit_status;
			$data['timelimit_month_first'] = '0';
			$data['timelimit_month_last'] = '0';
		}
		if($apr_status == "1"){
			$apr_first = $this->input->post("apr_first");
			$apr_last = $this->input->post("apr_last");
			if(!$this->myformcheck->isNumber($apr_first) || !$this->myformcheck->isNumber($apr_last)){
				$ret['msg'] = '利率限制无效';
			}
			elseif($apr_first > $apr_last){
				$ret['msg'] = '最小利率不能大于最大利率';
			}
			else {
				$data['apr_status'] = $apr_status;
				$data['apr_first'] = $apr_first;
				$data['apr_last'] = $apr_last;
			}
		}
		else {
			$data['apr_status'] = $apr_status;
			$data['apr_first'] = '0';
			$data['apr_last'] = '0';
		}
		if($award_status == "1"){
			$award_first = $this->input->post("award_first");
			$award_last = $this->input->post("award_last");
			if(!$this->myformcheck->IsDouble($award_first) || !$this->myformcheck->IsDouble($award_last)){
				$ret['msg'] = '奖励限制无效';
			}
			elseif($award_first > $award_last){
				$ret['msg'] = '最小奖励不能大于最大奖励';
			}
			else {
				$data['award_status'] = $award_status;
				$data['award_first'] = $award_first;
				$data['award_last'] = $award_last;
			}
		}
		else {
			$data['award_status'] = $award_status;
				$data['award_first'] = '0';
				$data['award_last'] = '0';
		}
		/*if($credit_rating_status == "1"){
			$credit_rating_first = $this->input->post("credit_rating_first");
			$credit_rating_last = $this->input->post("credit_rating_last");
			if(!array_key_exists($credit_rating_first,$this->Borrow_model->arrays('borrow_conset_credit')) || !array_key_exists($credit_rating_last,$this->Borrow_model->arrays('borrow_conset_credit'))){
				$ret['msg'] = '信誉限制无效';
			}
			elseif($credit_rating_first > $credit_rating_last){
				$ret['msg'] = '最小信誉不能大于最大信誉';
			}
			else {
				$data['credit_rating_status'] = $credit_rating_status;
				$data['credit_rating_first'] = $credit_rating_first;
				$data['credit_rating_last'] = $credit_rating_last;
			}
		}
		else {
			$data['credit_rating_status'] = $credit_rating_status;
			$data['credit_rating_first'] = '0';
			$data['credit_rating_last'] = '0';
		}*/
		if($ret['msg']){
			echo json_encode($ret);exit;
		}
  		
		$data['fstatus'] 	= $fstatus;
		
		$data['valid_start_time'] 			= $valid_start_time;
		$data['valid_end_time'] 			= $valid_end_time;
		$data['tender_account_min'] 			= $tender_account_min;
		$data['tender_account_max'] 			= $tender_account_max;
		$data['tender_type'] 			= $tender_type;
		
		
		$this->load->model('Borrow_model');
		if($typer == 'update') {
			$this->Borrow_model->update_borrow_auto($id, $data);
		}else {
			
			$this->Borrow_model->add_borrow_auto($data);
		}
		
		$ret['url'] = '/borrowauto/zhs_alist/index.html';
		
		echo json_encode($ret);
	}
	
	// 标的列表
	function zhs_alist(){
		$data = array();
		$user = $this->session->userdata('rsh_user');
		$data['where']['user_id'] = $user['user_id'];
		$data['select'] = 1;
		$this->load->model('Borrow_model');
		$vdata = $this->Borrow_model->get_borrow_auto_list($data);
		
		$vdata['borrow_type'] 			= $this->Borrow_model->arrays('borrow_type');//标的类型
		$vdata['borrow_time_limit'] 		= $this->Borrow_model->arrays('borrow_time_limit');//借款期限
		$vdata['borrow_style'] 			= $this->Borrow_model->arrays('borrow_style');//还款方式
		$vdata['borrow_conset_credit'] 		= $this->Borrow_model->arrays('borrow_conset_credit');//标的等级
		$vdata['num'] = $this->Borrow_model->get_count_auto_tender();
		
		$userdata = $this->get_user_info('borrowauto_alist','alist');
		$vdata['user'] = $userdata['user'];
		$vdata['user_vip'] = $userdata['user_vip'];
		
		$vdata['title'] = "自动投标设置列表".' - '.CON_KEYWORDS; 
		$vdata['tab'] = $userdata['tab'];
		$vdata['sub'] = "tender";
	
		$vdata['user_sub'] = "tender_invself";
		$vdata['sub_1'] = "会员中心";
		$vdata['sub_1_href'] = "/user/zhs_center.html";
		$vdata['sub_2'] = "自动投标";
		$vdata['sub_2_href'] = "/borrowauto/zhs_alist.html";
		$this->load->view('user/zhs_user_borrow_auto_list', $vdata);
	}

	function remove($id){
		$user = $this->session->userdata('rsh_user');
		$data['user_id']			= $user['user_id'];
		$data['id']					= $id;
		$this->load->model('Borrow_model');
		$this->Borrow_model->delete_borrow_auto($data);
		header("location:/borrowauto/zhs_alist/index.html");
		
	}
	
	function edit_view($id){
		$user = $this->session->userdata('rsh_user');
		$data['user_id'] = $user['user_id'];
		$this->load->model('Borrow_model');
		$borrow_auto_obj = $this->Borrow_model->get_borrow_auto_obj($id, $data);
		$vdata['borrow_auto_obj'] = $borrow_auto_obj;
		$this->load->model('Account_model', 'account');
		$account = $this->account->get_account($data['user_id']);
		$vdata['account'] = $account;
		$vdata['borrow_type'] 			= $this->Borrow_model->arrays('borrow_type');//标的类型
		$vdata['borrow_time_limit'] 		= $this->Borrow_model->arrays('borrow_time_limit');//借款期限
		$vdata['borrow_style'] 			= $this->Borrow_model->arrays('borrow_style');//还款方式
		$vdata['borrow_conset_credit'] 		= $this->Borrow_model->arrays('borrow_conset_credit');//标的等级
		$vdata['typer'] = "update";
		$vdata['sub'] = "tender";
		$vdata['user_sub'] = "tender_invself";
		$vdata['user_sub'] = "tender_invself";
		$vdata['sub_1'] = "会员中心";
		$vdata['sub_1_href'] = "/user/zhs_center.html";
		$vdata['sub_2'] = "自动投标";
		$vdata['sub_2_href'] = "/borrowauto/zhs_alist.html";
		$vdata['sub_3'] = "编辑自动发标";
		$vdata['sub_3_href'] = "/borrowauto/edit_view/".$id.".html";
		$this->load->view('user/zhs_user_borrow_auto_add', $vdata);
	}
=======
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/**
 * 自动投标设置
 * @author chenhuan
 *
 */
class Borrowauto extends MY_Controller {
    function __construct(){
		parent::__construct();
		/** 登陆验证 */
		$user = $this->session->userdata('rsh_user');
		if(!isset($user['user_id'])){
			$this->js->go('/login.html');
			exit;
		}
		
		$this->tab = 'user';
		$this->sub = 'tender';
	}
	
	/**
	 * 添加自动发标
	 * @param $ftype 标类型
	 */
	function add_view(){
		$this->load->helper(array('form'));
		$this->load->model('Borrow_model');
		$data = $this->get_user_info('borrowauto_add','alist');
		$this->load->model('Account_model', 'account');
		$account = $this->account->get_account($data['user']['user_id']);
		$data['account'] = $account;
		$data['borrow_type'] 			= $this->Borrow_model->arrays('borrow_type');//标的类型
		$data['borrow_time_limit'] 		= $this->Borrow_model->arrays('borrow_time_limit');//借款期限
		$data['borrow_style'] 			= $this->Borrow_model->arrays('borrow_style');//还款方式
		$data['borrow_conset_credit'] 		= $this->Borrow_model->arrays('borrow_conset_credit');//标的等级
		$data['title'] 					= "自动投标设置".' - '.CON_KEYWORDS; 
		$data['valid_start_time'] = date('Y-m-d',time());
		$data['valid_end_time'] = date('Y-m-d',time()+2*3600*24);
		$data['typer'] = "add";
		$data['sub'] = "tender";
		$data['user_sub'] = "tender_invself";
		$data['sub_1'] = "会员中心";
		$data['sub_1_href'] = "/user/zhs_center.html";
		$data['sub_2'] = "自动投标";
		$data['sub_2_href'] = "/borrowauto/zhs_alist.html";
		$data['sub_3'] = "添加自动发标";
		$data['sub_3_href'] = "/borrowauto/add_view.html";
		$this->load->view('user/zhs_user_borrow_auto_add', $data);
	}
	
	/**
	 *	新增自动购买标的
	 */
	function add(){
		$ret = array(
			'msg' => '',
			'url' => '',
		);
		$fstatus 				= $this->input->post("fstatus");//是否启用
		$tender_type 				= $this->input->post("tender_type");//标的类型
		$tender_account_min 		= $this->input->post("tender_account_min");//按金额，最大金额
		$tender_account_max 		= $this->input->post("tender_account_max");//按金额，最小金额
		$borrow_style_status 			= $this->input->post("borrow_style_status")?$this->input->post("borrow_style_status"):'0';//还款方式
		$retain_money_status			= $this->input->post("retain_money_status")?$this->input->post("retain_money_status"):'0';//保留金额
		$timelimit_status 			= $this->input->post("timelimit_status")?$this->input->post("timelimit_status"):'0';//标的期限
		$apr_status 			= $this->input->post("apr_status")?$this->input->post("apr_status"):'0';//利率选项
		$award_status 			= $this->input->post("award_status")?$this->input->post("award_status"):'0';//奖励选项
		//$credit_rating_status			= $this->input->post("credit_rating_status")?$this->input->post("credit_rating_status"):'0';//信誉等级
		
		$valid_start_time_post = $this->input->post("valid_start_time");
		$valid_end_time_post = $this->input->post("valid_end_time");
		$valid_start_time 			= strtotime($valid_start_time_post.' 00:00:00');//有效开始时间
		$valid_end_time 			= strtotime($valid_end_time_post.' 23:59:59');//有效结束时间
		
		$user = $this->session->userdata('rsh_user');
		$data['user_id']= $user['user_id'];
		
		$this->load->model('Borrow_model');
		if(!array_key_exists($tender_type,$this->Borrow_model->arrays('borrow_type'))){
			$ret['msg'] = '标的类型无效';
		}elseif(!$this->myformcheck->IsDouble($tender_account_min) || !$this->myformcheck->IsDouble($tender_account_max)){
			$ret['msg'] = '单笔投资金额无效';
		}elseif($tender_account_min > $tender_account_max){
			$ret['msg'] = '单笔最小投资金额不能大于最大投资金额';
		}elseif($tender_account_min <50){
			$ret['msg'] = '单笔最小投资金额不能小于50';
		}elseif($tender_account_max > 100000){
			$ret['msg'] = '单笔最大投资金额不能大于10W';
		}elseif($borrow_style_status != "1" && $borrow_style_status != "0"){
			$ret['msg'] = '还款方式是否启动无效';
		}elseif($retain_money_status != "1" && $retain_money_status != "0"){
			$ret['msg'] = '保留金额是否启动无效';
		}elseif($timelimit_status != "1" && $timelimit_status != "0"){
			$ret['msg'] = '标的期限是否启动无效';
		}/*elseif($apr_status != "1" && $apr_status != "0"){
			$ret['msg'] = '利率选项是否启动无效';
		}*/elseif($award_status != "1" && $award_status != "0"){
			$ret['msg'] = '奖励选项是否启动无效';
		}elseif($valid_start_time > $valid_end_time){
			$ret['msg'] = '开始时间不能大于结束时间';	
		}
		$id = '';
		
		$typer = $this->input->post("typer");
		if($typer == 'update') $id = $this->input->post("id");
		if(!$this->Borrow_model->is_date_borrow_auto(array('user_id'=>$data['user_id'],'valid_start_time'=>$valid_start_time,'valid_end_time'=>$valid_end_time,'id'=>$id))){
			$ret['msg'] = '开始时间与结束时间不可与其它自动投标的时间重合';
		}
		if($typer != 'update'){
			$count = $this->Borrow_model->count_borrow_auto(array('user_id'=>$data['user_id'])); 
			if($count > 2) {
				$ret['msg'] = '您最多可以创建 3 条自动投标规则';
			}
		}
		if($ret['msg']){
			echo json_encode($ret);exit;
		}
		
		if($borrow_style_status == "1"){
			$borrow_style = $this->input->post("borrow_style");
			if(!array_key_exists($borrow_style,$this->Borrow_model->arrays('borrow_style'))){
				$ret['msg'] = '还款方式无效';
			}
			else {
				$data['borrow_style_status'] = $borrow_style_status;
				$data['borrow_style'] = $borrow_style;
			}
		}
		else {
			$data['borrow_style_status'] = $borrow_style_status;
			$data['borrow_style'] = '';
		}
		if($retain_money_status == "1"){
			$retain_money = $this->input->post("retain_money");
			if(!$this->myformcheck->IsDouble($retain_money)){
				$ret['msg'] = '保留金额无效';
			}
			else {
				$data['retain_money_status'] = $retain_money_status;
				$data['retain_money'] = $retain_money;
			}
		}
		else {
			$data['retain_money_status'] = $retain_money_status;
			$data['retain_money'] = '0.00';
		}
		
		if($timelimit_status == "1"){
			$timelimit_month_first = $this->input->post("timelimit_month_first");
			$timelimit_month_last = $this->input->post("timelimit_month_last");
			if(!array_key_exists($timelimit_month_first,$this->Borrow_model->arrays('borrow_time_limit')) || !array_key_exists($timelimit_month_last,$this->Borrow_model->arrays('borrow_time_limit'))){
				$ret['msg'] = '标的期限无效';
			}
			elseif($timelimit_month_first > $timelimit_month_last){
				$ret['msg'] = '标的最小期限不能大于最大期限';
			}
			else {
				$data['timelimit_status'] = $timelimit_status;
				$data['timelimit_month_first'] = $timelimit_month_first;
				$data['timelimit_month_last'] = $timelimit_month_last;
			}
		}
		else {
			$data['timelimit_status'] = $timelimit_status;
			$data['timelimit_month_first'] = '0';
			$data['timelimit_month_last'] = '0';
		}
		if($apr_status == "1"){
			$apr_first = $this->input->post("apr_first");
			$apr_last = $this->input->post("apr_last");
			if(!$this->myformcheck->isNumber($apr_first) || !$this->myformcheck->isNumber($apr_last)){
				$ret['msg'] = '利率限制无效';
			}
			elseif($apr_first > $apr_last){
				$ret['msg'] = '最小利率不能大于最大利率';
			}
			else {
				$data['apr_status'] = $apr_status;
				$data['apr_first'] = $apr_first;
				$data['apr_last'] = $apr_last;
			}
		}
		else {
			$data['apr_status'] = $apr_status;
			$data['apr_first'] = '0';
			$data['apr_last'] = '0';
		}
		if($award_status == "1"){
			$award_first = $this->input->post("award_first");
			$award_last = $this->input->post("award_last");
			if(!$this->myformcheck->IsDouble($award_first) || !$this->myformcheck->IsDouble($award_last)){
				$ret['msg'] = '奖励限制无效';
			}
			elseif($award_first > $award_last){
				$ret['msg'] = '最小奖励不能大于最大奖励';
			}
			else {
				$data['award_status'] = $award_status;
				$data['award_first'] = $award_first;
				$data['award_last'] = $award_last;
			}
		}
		else {
			$data['award_status'] = $award_status;
				$data['award_first'] = '0';
				$data['award_last'] = '0';
		}
		/*if($credit_rating_status == "1"){
			$credit_rating_first = $this->input->post("credit_rating_first");
			$credit_rating_last = $this->input->post("credit_rating_last");
			if(!array_key_exists($credit_rating_first,$this->Borrow_model->arrays('borrow_conset_credit')) || !array_key_exists($credit_rating_last,$this->Borrow_model->arrays('borrow_conset_credit'))){
				$ret['msg'] = '信誉限制无效';
			}
			elseif($credit_rating_first > $credit_rating_last){
				$ret['msg'] = '最小信誉不能大于最大信誉';
			}
			else {
				$data['credit_rating_status'] = $credit_rating_status;
				$data['credit_rating_first'] = $credit_rating_first;
				$data['credit_rating_last'] = $credit_rating_last;
			}
		}
		else {
			$data['credit_rating_status'] = $credit_rating_status;
			$data['credit_rating_first'] = '0';
			$data['credit_rating_last'] = '0';
		}*/
		if($ret['msg']){
			echo json_encode($ret);exit;
		}
  		
		$data['fstatus'] 	= $fstatus;
		
		$data['valid_start_time'] 			= $valid_start_time;
		$data['valid_end_time'] 			= $valid_end_time;
		$data['tender_account_min'] 			= $tender_account_min;
		$data['tender_account_max'] 			= $tender_account_max;
		$data['tender_type'] 			= $tender_type;
		
		
		$this->load->model('Borrow_model');
		if($typer == 'update') {
			$this->Borrow_model->update_borrow_auto($id, $data);
		}else {
			
			$this->Borrow_model->add_borrow_auto($data);
		}
		
		$ret['url'] = '/borrowauto/zhs_alist/index.html';
		
		echo json_encode($ret);
	}
	
	// 标的列表
	function zhs_alist(){
		$data = array();
		$user = $this->session->userdata('rsh_user');
		$data['where']['user_id'] = $user['user_id'];
		$data['select'] = 1;
		$this->load->model('Borrow_model');
		$vdata = $this->Borrow_model->get_borrow_auto_list($data);
		
		$vdata['borrow_type'] 			= $this->Borrow_model->arrays('borrow_type');//标的类型
		$vdata['borrow_time_limit'] 		= $this->Borrow_model->arrays('borrow_time_limit');//借款期限
		$vdata['borrow_style'] 			= $this->Borrow_model->arrays('borrow_style');//还款方式
		$vdata['borrow_conset_credit'] 		= $this->Borrow_model->arrays('borrow_conset_credit');//标的等级
		$vdata['num'] = $this->Borrow_model->get_count_auto_tender();
		
		$userdata = $this->get_user_info('borrowauto_alist','alist');
		$vdata['user'] = $userdata['user'];
		$vdata['user_vip'] = $userdata['user_vip'];
		
		$vdata['title'] = "自动投标设置列表".' - '.CON_KEYWORDS; 
		$vdata['tab'] = $userdata['tab'];
		$vdata['sub'] = "tender";
	
		$vdata['user_sub'] = "tender_invself";
		$vdata['sub_1'] = "会员中心";
		$vdata['sub_1_href'] = "/user/zhs_center.html";
		$vdata['sub_2'] = "自动投标";
		$vdata['sub_2_href'] = "/borrowauto/zhs_alist.html";
		$this->load->view('user/zhs_user_borrow_auto_list', $vdata);
	}

	function remove($id){
		$user = $this->session->userdata('rsh_user');
		$data['user_id']			= $user['user_id'];
		$data['id']					= $id;
		$this->load->model('Borrow_model');
		$this->Borrow_model->delete_borrow_auto($data);
		header("location:/borrowauto/zhs_alist/index.html");
		
	}
	
	function edit_view($id){
		$user = $this->session->userdata('rsh_user');
		$data['user_id'] = $user['user_id'];
		$this->load->model('Borrow_model');
		$borrow_auto_obj = $this->Borrow_model->get_borrow_auto_obj($id, $data);
		$vdata['borrow_auto_obj'] = $borrow_auto_obj;
		$this->load->model('Account_model', 'account');
		$account = $this->account->get_account($data['user_id']);
		$vdata['account'] = $account;
		$vdata['borrow_type'] 			= $this->Borrow_model->arrays('borrow_type');//标的类型
		$vdata['borrow_time_limit'] 		= $this->Borrow_model->arrays('borrow_time_limit');//借款期限
		$vdata['borrow_style'] 			= $this->Borrow_model->arrays('borrow_style');//还款方式
		$vdata['borrow_conset_credit'] 		= $this->Borrow_model->arrays('borrow_conset_credit');//标的等级
		$vdata['typer'] = "update";
		$vdata['sub'] = "tender";
		$vdata['user_sub'] = "tender_invself";
		$vdata['user_sub'] = "tender_invself";
		$vdata['sub_1'] = "会员中心";
		$vdata['sub_1_href'] = "/user/zhs_center.html";
		$vdata['sub_2'] = "自动投标";
		$vdata['sub_2_href'] = "/borrowauto/zhs_alist.html";
		$vdata['sub_3'] = "编辑自动发标";
		$vdata['sub_3_href'] = "/borrowauto/edit_view/".$id.".html";
		$this->load->view('user/zhs_user_borrow_auto_add', $vdata);
	}
>>>>>>> d47623b610d79a4eeb489500830c00d70933f414
}